<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        padding: 0;
        margin: 0;
        box-sizing: border-box;
      }
      .container {
        height: 100vh;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .input {
        box-sizing: border-box;
        position: relative;
        width: 260px;
      }
      .input #Textarea {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: #fff;
        border: 1px solid #333;
        padding: 8px 10px;
        min-height: fit-content;
        max-height: 240px;
        overflow-y: auto;
        line-height: 20px;
        outline: none;
        resize: none;
        font-size: 16px;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="input">
        <div id="Textarea" contenteditable="true"></div>
      </div>
    </div>
  </body>
  <script>
    const Textarea = document.getElementById("Textarea");
    Textarea.onpaste = (event) => {
      // 阻止默认的粘贴行为
      event.preventDefault();
      // 获取粘贴的文本数据
      const text = (event.clipboardData || window.clipboardData).getData(
        "text"
      );
      // 插入纯文本到光标位置
      document.execCommand("insertText", false, text);
    };
  </script>
</html>
